package com.work.game.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;

import androidx.appcompat.widget.AppCompatCheckBox;

public class CircleCheckBox extends AppCompatCheckBox {

    public CircleCheckBox(Context context) {
        super(context);
    }

    public CircleCheckBox(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CircleCheckBox(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Drawable drawable = getButtonDrawable();
        if (drawable != null) {
            int width = drawable.getIntrinsicWidth();
            int height = drawable.getIntrinsicHeight();
            int radius = Math.max(width, height) / 2;

            float x = getWidth() / 2f;
            float y = getHeight() / 2f;

            canvas.drawCircle(x, y, radius, getPaint());
        } else {
            super.onDraw(canvas);
        }
    }
}
